package ua.lviv.franko.visualisation;

import java.awt.Color;
import java.awt.Dimension;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.xy.XYSeriesCollection;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * NewOkCancelDialog.java
 *
 * Created on 26 лист 2009, 23:49:21
 */

/**
 * 
 * @author mark
 */
public class NewOkCancelDialog extends javax.swing.JDialog {
	/**
	 * 
	 */
	private static final long	serialVersionUID	= 6161870128899109067L;
	/** A return status code - returned if Cancel button has been pressed */
	public static final int		RET_CANCEL			= 0;
	/** A return status code - returned if OK button has been pressed */
	public static final int		RET_OK				= 1;
	XYSeriesCollection			col;

	private static Dimension	size				= new Dimension(800, 600);

	private int					returnStatus		= RET_CANCEL;

	/** Creates new form NewOkCancelDialog */
	public NewOkCancelDialog(java.awt.Frame parent, boolean modal, XYSeriesCollection col) {
		super(parent, modal);
		initComponents();
		String series1 = "розвязок одновимірної задачі";
		// column keys...
		String category1 = "";
		// create the dataset...
		DefaultCategoryDataset dataset = new DefaultCategoryDataset();
		dataset.addValue(1.0, series1, category1);
		JFreeChart chart = ChartFactory.createXYLineChart("результат", "x", "y", col, PlotOrientation.VERTICAL, true, true, false);

		chart.setBackgroundPaint(Color.white);

		ChartPanel chartPanel = new ChartPanel(chart);
		chartPanel.setFillZoomRectangle(true);
		chartPanel.setMouseWheelEnabled(true);
		chartPanel.setPreferredSize(size);
		setContentPane(chartPanel);
	}

	/** @return the return status of this dialog - one of RET_OK or RET_CANCEL */
	public int getReturnStatus() {
		return returnStatus;
	}

	/** Closes the dialog */
	private void closeDialog(java.awt.event.WindowEvent evt) {// GEN-FIRST:event_closeDialog
		doClose(RET_CANCEL);
	}// GEN-LAST:event_closeDialog

	private void doClose(int retStatus) {
		returnStatus = retStatus;
		setVisible(false);
		dispose();
	}

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	private void initComponents() {

		addWindowListener(new java.awt.event.WindowAdapter() {
			public void windowClosing(java.awt.event.WindowEvent evt) {
				closeDialog(evt);
			}
		});

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, (int) size.getWidth(), Short.MAX_VALUE));
		layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, (int) size.getHeight(), Short.MAX_VALUE));

		pack();
	}// </editor-fold>//GEN-END:initComponents

	// Variables declaration - do not modify//GEN-BEGIN:variables
	// End of variables declaration//GEN-END:variables

	/**
	 * @param args
	 *            the command line arguments
	 */
	public static void main(String args[]) {
		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run() {
				NewOkCancelDialog dialog = new NewOkCancelDialog(new javax.swing.JFrame(), true, null);
				dialog.addWindowListener(new java.awt.event.WindowAdapter() {
					public void windowClosing(java.awt.event.WindowEvent e) {
						System.exit(0);
					}
				});
				dialog.setVisible(true);
			}
		});
	}
}
